/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package abricots.game;

import abricots.entity.*;
import abricots.entity.simulator.ServerEntitySimulator;
import abricots.entity.state.ControllableEntityState;
import abricots.entity.state.EntityState;
import abricots.entity.state.ServerEntityState;

/**
 *
 * @author charly
 */
public class EntityFactory {

    public static Entity build(int type) {
        Entity entity = null;
        switch (type) {
            case GameConstants.ENTITY_TYPE_ID_ROOT: {
                entity = new RootEntity();
                return entity;
            }
            case GameConstants.ENTITY_TYPE_ID_BALL: {
                entity = new BallEntity();
                break;
            }
            case GameConstants.ENTITY_TYPE_ID_SERVER: {
                entity = new ServerEntity();
                break;
            }
            case GameConstants.ENTITY_TYPE_ID_PLAYER: {
                entity = new PlayerEntity(null);
                break;
            }
        }
        if (entity == null) {
            return null;
        }
        entity.getStateManager().addState(buildStartState(type));
        return entity;
    }

    public static EntityState buildStartState(int type) {
        switch (type) {
            case GameConstants.ENTITY_TYPE_ID_BALL: {
                return new ControllableEntityState(false, false, false, false, 100, 100, 0, 0, -1, -1);
            }
            case GameConstants.ENTITY_TYPE_ID_SERVER: {
                return new ServerEntityState(false, 400, 570, ServerEntitySimulator.SPEED, 0, -1, -1);
            }
        }
        return null;
    }
}
